#include<stdio.h>
struct student
{
	int id;
	char Class[20];
	char name[20];
	float score1;
	float score2;
	float score3;
	float average;
};
int main()
{
	int n, i, max = 0;
	struct student st[1005];
	scanf("%d", &n);//input
	for (i = 0; i < n; i++)
	{
		scanf("%d %s %s %f %f %f", &st[i].id, st[i].Class, st[i].name,
			&st[i].score1, &st[i].score2, &st[i].score3);
		st[i].average = (st[i].score1 + st[i].score2 + st[i].score3) / 3;
	}
	for (i = 1; i < n; i++)
	{
		if (st[max].average < st[i].average)max = i;
	}
	for (i = 0; i < n; i++)//output
	{
		printf("%s %.1f\n", st[i].name, st[i].average);
	}
	printf("%d %s %s %.1f %.1f %.1f %.1f\n", st[max].id, st[max].Class, st[max].name,
		st[max].score1, st[max].score2, st[max].score3, st[max].average);
	return 0;
}